/*************************************************************************************************
 * The skeletion multi-tables database for Tokyo Cabinet
 *                                       Copyright (C) 2009 Riceball LEE(riceballl@hotmail.com)
 *************************************************************************************************/


#ifndef _TCSKBDB_H                         /* duplication check */
#define _TCSKBDB_H

#if defined(__cplusplus)
#define __TCSKBDB_CLINKAGEBEGIN extern "C" {
#define __TCSKBDB_CLINKAGEEND }
#else
#define __TCSKBDB_CLINKAGEBEGIN
#define __TCSKBDB_CLINKAGEEND
#endif
__TCSKBDB_CLINKAGEBEGIN

#include <tcadb.h>
#include <tctdb.h>
#include <tcbdb.h>

#define IDXCONFIGKEY     "_DB/index/_conf/"             // the prefix of the index config key.
#define IDXKEY           "_DB/index/"                   // the prefix of the index key.
#define MAXKEYLEN        2047

//MUST USE THE TCESUCCESS, TCEINVALID, TCENOREC, TCEKEEP , or fatal error.
//enum {                                   /* enumeration for error codes */
//  TCESUCCESS,                            /* success */
//  TCETHREAD,                             /* threading error */
//  TCEINVALID,                            /* invalid operation */
//  TCENOFILE,                             /* file not found */
//  TCENOPERM,                             /* no permission */
//  TCEMETA,                               /* invalid meta data */
//  TCERHEAD,                              /* invalid record header */
//  TCEOPEN,                               /* open error */
//  TCECLOSE,                              /* close error */
//  TCETRUNC,                              /* trunc error */
//  TCESYNC,                               /* sync error */
//  TCESTAT,                               /* stat error */
//  TCESEEK,                               /* seek error */
//  TCEREAD,                               /* read error */
//  TCEWRITE,                              /* write error */
//  TCEMMAP,                               /* mmap error */
//  TCELOCK,                               /* lock error */
//  TCEUNLINK,                             /* unlink error */
//  TCERENAME,                             /* rename error */
//  TCEMKDIR,                              /* mkdir error */
//  TCERMDIR,                              /* rmdir error */
//  TCEKEEP,                               /* existing record */
//  TCENOREC,                              /* no record found */
//  TCEMISC = 9999                         /* miscellaneous error */
//  TCESKELBDB= 10000,                         /* the SKELBDB custom error */
//  TCEREMOVEINDEX                             /* remove index error */
//};

typedef struct {                         // type of structure for skel bdb database
  TCBDB *bdb;                          // inner B++ Tree DB database objects
  BDBCUR *cur;                           /* cursor of B+ tree */
} SKELBDB;

/*************************************************************************************************
 * API
 *************************************************************************************************/
bool tcADBSetSkelBDB(TCADB *adb);
//void tcSkelBDBSetEcode(TCBDB *bdb, int ecode, const char *filename, int line, const char *func);
//const char *tcSkelBDBErrMsg(int ecode);

__TCSKBDB_CLINKAGEEND
#endif                                   /* duplication check */


/* END OF FILE */
